﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Infrastructure.UI
{
    public class Util
    {
        #region PrtSc

        private static System.Drawing.Image PrtSc()
        {
            System.Drawing.Image img = null;
            SendKeys.SendWait("^{PRTSC}");
            IDataObject iData = Clipboard.GetDataObject();
            if (iData == null) return null;

            if (iData.GetDataPresent(DataFormats.Bitmap))
            {
                img = (System.Drawing.Image)iData.GetData(DataFormats.Bitmap);
            }
            return img;
        }


        public static byte[] PrtSc2Byte()
        {
            System.Drawing.Image img = PrtSc();
            byte[] bytes = null;
            if (img != null)
            {
                var stream = new System.IO.MemoryStream();
                try
                {
                    img.Save(stream, System.Drawing.Imaging.ImageFormat.Gif);
                    bytes = stream.ToArray();
                }
                finally
                {
                    stream.Close();
                }
            }
            return bytes;
        }


        #endregion		
    }
}
